
#include<bits/stdc++.h>
	using namespace std;

bool ispalindrome(int n)
{
	int arr[10]; int digit = 0;
	while (n) { arr[digit] = n % 10; n /= 10; digit++; }
	for (int i = 0; i < digit; i++)if (arr[i] != arr[digit - i - 1])return false;
	return true;
}
bool isprime(int n)
{
	if (n < 2) return false;
	for (int i = 0; i < sqrt(n); i++) if (n % i == 0) return false;
	return true;
}
int main()
{
	int left, right;
	cin >> left >> right;
	for (int i = left; i <= right; i++)
	{
		if (isprime(i) && ispalindrome(i))
		{
			cout << i << endl;
		}
	}
	return 0;

}
